package com.qf.exception;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import com.qf.common.R;
/**
 * 全局异常处理器
 */
@RestControllerAdvice

public class GlobalExceptionHandler {

    @ExceptionHandler(CustomerException.class)
    public R customerException(CustomerException e){
        return R.fail(e.getCode(),e.getMsg());
    }
    @ExceptionHandler(Exception.class)
    public R exception(Exception e){
        e.printStackTrace();
        return R.fail("未知异常");
    }
}
